package com.clear.subject.application.controller;

import com.alibaba.fastjson.JSON;
import com.clear.subject.common.entity.PageResult;
import com.clear.subject.infra.basic.entity.SubjectInfoEs;
import com.clear.subject.infra.basic.service.SubjectEsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/subject/es/")
@Slf4j
public class TestEsController {

    @Resource
    private SubjectEsService subjectEsService;

    @PostMapping("querySubjectByKeyWord")
    public void querySubjectByKeyWord() {
        try {
            SubjectInfoEs subjectInfoEs = new SubjectInfoEs();
            subjectInfoEs.setKeyWord("Oracle");
            subjectInfoEs.setSubjectType(4);
            PageResult<SubjectInfoEs> result = subjectEsService.querySubjectList(subjectInfoEs);
            log.info("TestEsController.querySubjectByKeyWord.result:{}", JSON.toJSONString(result));
        } catch (Exception e) {
            log.error("TestEsController.querySubjectByKeyWord.error:{}", e.getMessage(),e);
        }

    }
}
